import requests
import execjs
with open('huiNong2.js', 'r',encoding='utf-8') as f:
    js = f.read()
    ctx = execjs.compile(js)
    header = ctx.call('get_header')
    # print(header)
headers = {
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    'content-type': 'application/json',
    'origin': 'https://m.cnhnb.com',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://m.cnhnb.com/',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1',
}
# headers = {
#     'accept': 'application/json, text/plain, */*',
#     'accept-language': 'zh-CN,zh;q=0.9',
#     'cache-control': 'no-cache',
#     'content-type': 'application/json',
#     'origin': 'https://m.cnhnb.com',
#     'pragma': 'no-cache',
#     'priority': 'u=1, i',
#     'referer': 'https://m.cnhnb.com/',
#     'sec-ch-ua': '"Not/A)Brand";v="8", "Chromium";v="126", "Google Chrome";v="126"',
#     'sec-ch-ua-mobile': '?1',
#     'sec-ch-ua-platform': '"Android"',
#     'sec-fetch-dest': 'empty',
#     'sec-fetch-mode': 'cors',
#     'sec-fetch-site': 'same-site',
#     'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Mobile Safari/537.36',
#     'x-b3-traceid': '0LXV7SAL494LQ4GA',
#     'x-client-appid': '5',
#     'x-client-environment': 'pro',xxx
#     'x-client-id': '0699b81-3b36-4129-bae0-7767153e9',
#     'x-client-nonce': 'f6e0f13e357ce83038942a2b5c8ea09f',
#     'x-client-page': '/p/xigua/',
#     'x-client-sid': 'S_0LXV7S5E2X4H7GCT',
#     'x-client-sign': 'b8ee5b03a37353e3eb165150292bb4afdbec9d9ceafb8053a64825361cbd4545e8af7c76ec91cacd51314bd228e1c1c9',
#     'x-client-time': '1719368791960',
#     'x-hn-job': 'If you see these message, I hope you dont hack us, I hope you can join us! Please visit https://www.cnhnkj.com/job.html',
# }
headers.update(header)

print("headers:", headers)
json_data = {
    'pageNumber': 2,
    'pageSize': 10,
    'cateId3': 2001243,
    'cate3Name': '西瓜',
    'ad_ch': 0,
}

response = requests.post('https://appapi.cnhnb.com/esearch-poly/api/transform/supply/v509/list', headers=headers, json=json_data)

for i in response.json()['data']['datas']:
    print(i)